#[macro_use]
extern crate diesel;
extern crate rocket;
extern crate rocket_sync_db_pools;

use rocket::{catchers, routes};

mod db;
mod mappers;
mod models;
mod routes;
mod schema;

use db::DbConn;
use routes::{not_found::not_found, todos, users};

#[rocket::main]
async fn main() {
  let server = rocket::build()
    .mount(
      "/",
      routes![
        // ---- todo router ------
        todos::get_todo,
        todos::view_todo,
        todos::create_todo,
        todos::update_todo,
        todos::delete_todo,
        // ---- user router ------
        users::get_user,
        users::view_user,
        users::create_user,
        users::update_user,
        users::delete_user,
      ],
    )
    .register("/", catchers![not_found])
    .attach(DbConn::fairing());

  server.launch().await.unwrap();
}
